﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Security;

namespace NOSDC.Areas.Admin.Models
{
    public class UserViewModel
    {
        public string Username { get; private set; }
        public string FirstName { get; private set; }
        public string LastName { get; private set; }
        public string Role { get; set; }
        public IEnumerable<RoleViewModel> AllRoles { get; set; }

        public UserViewModel(string username, string firstname, string lastname, string role)
        {
            Username = username;
            FirstName = firstname;
            LastName = lastname;
            Role = role;
            AllRoles = Roles.GetAllRoles().Select(r => new RoleViewModel
            {
                Name = r,
                Selected = Roles.IsUserInRole(username, role)
            }).ToList();
        }
    }

    public class RoleViewModel
    {
        public string Name { get; set; }
        public bool Selected { get; set; }
    }
}